//获取所有的菜品分类
function categoryListApi() {
    return $axios({
        'url': 'http://localhost:18080/dish/category/list',
        'method': 'get',
    })
}

//获取菜品分类对应的菜品
function dishListApi(data) {
    return $axios({
        'url': 'http://localhost:18080/dish/dish/list',
        'method': 'get',
        params: {...data}
    })
}

//获取菜品分类对应的套餐
function setmealListApi(data) {
    return $axios({
        'url': 'http://localhost:18080/dish/setmeal/list',
        'method': 'get',
        params: {...data}
    })
}

//获取购物车内商品的集合
function cartListApi(data) {
    const Authorization = localStorage.getItem('Authorization')

    return $axios({
        'url': 'http://localhost:18080/shoppingCart/shoppingCart/list',
        //'url': '/front/cartData.json',
        'method': 'get',
        headers: {
            'Authorization': `${Authorization}`
        },
        params: {...data}
    })
}

//购物车中添加商品
function addCartApi(data) {
    const Authorization = localStorage.getItem('Authorization')

    return $axios({
        'url': 'http://localhost:18080/shoppingCart/shoppingCart/add',
        'method': 'post',
        headers: {
            'Authorization': `${Authorization}`
        },
        data
    })
}

//购物车中修改商品
function updateCartApi(data) {
    const Authorization = localStorage.getItem('Authorization')

    return $axios({
        'url': 'http://localhost:18080/shoppingCart/shoppingCart/sub',
        'method': 'post',
        headers: {
            'Authorization': `${Authorization}`
        },
        data
    })
}

//删除购物车的商品
function clearCartApi() {
    const Authorization = localStorage.getItem('Authorization')

    return $axios({
        'url': 'http://localhost:18080/shoppingCart/shoppingCart/clean',
        'method': 'delete',
        headers: {
            'Authorization': `${Authorization}`
        }
    })
}

//获取套餐的全部菜品
function setMealDishDetailsApi(id) {
    return $axios({
        'url': `http://localhost:18080/dish/setmeal/dish/${id}`,
        'method': 'get',
    })
}


